home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWStream / Sources / FWLocMap.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  4.0 KB  |  96 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWLocMap.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFound.hpp"
  11.  
  12. #ifndef FWARDYNA_H
  13. #include "FWArDyna.h"
  14. #endif
  15.  
  16. #if FW_LIB_EXPORT_PRAGMAS
  17. #pragma lib_export on
  18. #endif
  19.  
  20. //========================================================================================
  21. // Any DLL that declares dynamically archivable classes must have its own local copies
  22. // of two FW_CDynamicArchiver maps.  This .cpp file declares storage for these local maps.
  23. // The compile output (.obj) of this file must be *statically* linked into *each* DLL
  24. // that declares archivable classes.
  25. //========================================================================================
  26.  
  27.  
  28. //----------------------------------------------------------------------------------------
  29. //    FW_CDynamicArchiver Local maps
  30. //
  31. //        These maps cannot be a static objects, because we must guarantee
  32. //        that they are initialized before any FW_CDynamicArchiver is initialized.
  33. //        We achieve this by using the accessor functions below.  The first time the
  34. //        accessor function is called, the corresponding data structure is initialized.
  35. //
  36. //----------------------------------------------------------------------------------------
  37.  
  38. FW_CPrivNameToLabelMap * FW_CDynamicArchiver::gLocalClassNameToClassLabelMap = 0;
  39. FW_CPrivLabelToIOFunctionMap * FW_CDynamicArchiver::gLocalClassLabelToObjectIOFunctionMap = 0;
  40.  
  41. //----------------------------------------------------------------------------------------
  42. //    FW_PrivGetLocalNameToLabelMap
  43. //----------------------------------------------------------------------------------------
  44.  
  45. FW_ARCHIVE_FUNC_ATTR FW_CPrivNameToLabelMap& FW_PrivGetLocalNameToLabelMap()
  46. {
  47.     if (FW_CDynamicArchiver::gLocalClassNameToClassLabelMap == 0)
  48.     {
  49.         FW_CDynamicArchiver::gLocalClassNameToClassLabelMap = new FW_CPrivNameToLabelMap();
  50.     }
  51.     return *FW_CDynamicArchiver::gLocalClassNameToClassLabelMap;
  52. }
  53.  
  54. //----------------------------------------------------------------------------------------
  55. //    FW_PrivGetLocalLabelToIOFunctionMap
  56. //----------------------------------------------------------------------------------------
  57.  
  58. FW_ARCHIVE_FUNC_ATTR FW_CPrivLabelToIOFunctionMap& FW_PrivGetLocalLabelToIOFunctionMap()
  59. {
  60.     if (FW_CDynamicArchiver::gLocalClassLabelToObjectIOFunctionMap == 0)
  61.     {
  62.         FW_CDynamicArchiver::gLocalClassLabelToObjectIOFunctionMap = new FW_CPrivLabelToIOFunctionMap();
  63.     }
  64.     return *FW_CDynamicArchiver::gLocalClassLabelToObjectIOFunctionMap;
  65. }
  66.  
  67. //----------------------------------------------------------------------------------------
  68. //    FW_MergeArchiverMaps
  69. //
  70. //        This function will work if and only if it is statically linked into *each*
  71. //        DLL that has archivable class infos.  Each copy of this function must be
  72. //        called during application initialization (before any objects are read from
  73. //        or written to an archive.  Since all copies have the same name, the DLL
  74. //        developer must provide a uniquely named function that calls this function,
  75. //        and then arrange for that function to be statically linked to this function.
  76. //        The application developer can then call the uniquely named, DLL-specific function.
  77. //        Note that for safety, this function should not be exported if the build
  78. //        environment supports that feature.
  79. //
  80. //----------------------------------------------------------------------------------------
  81.  
  82. void FW_ARCHIVE_FUNC_ATTR FW_MergeArchiverMaps() 
  83. {
  84.     FW_CDynamicArchiver::MergeNameToLabelMaps(FW_PrivGetLocalNameToLabelMap(),
  85.                         FW_CDynamicArchiver::GetNameToLabelMap());
  86.     FW_CDynamicArchiver::MergeLabelToIOFunctionMaps(FW_PrivGetLocalLabelToIOFunctionMap(),
  87.                                 FW_CDynamicArchiver::GetLabelToIOFunctionMap());
  88. }
  89.  
  90. #ifdef FW_BUILD_WIN16
  91. extern "C" void FW_FUNC_ATTR FW_MERGEARCHIVERMAPSHOOK()
  92. {
  93.     FW_MergeArchiverMaps();
  94. }
  95. #endif
  96.